package game.dlg
{
	import flash.display.Bitmap;
	import flash.events.TouchEvent;
	
	import game.core.FLPan;
	import game.core.FLPoint;
	
	public class PanDialog extends GameDialog
	{
		[Embed(source="/../embeds/a001.png")]
		public static var PanBg:Class;
		public var bg:Bitmap;
		public var p:GamePoint;
		public static var ORG_WIDTH:int = 640;
		public var flPan:FLPan;
		public var points:Array=[];
		public function PanDialog()
		{
			super();
			init();
		}
		
		public function init():void
		{
			bg = new PanBg() as Bitmap;
			if(bg!=null){
				this.addChild(bg);
			}
			
			this.addEventListener(TouchEvent.TOUCH_TAP,onTouch);
			
			initPan();
			
			this.scaleX = 1080 /640;
			this.scaleY = 1080 /640;
		}
		
		public function initPan():void
		{
			flPan = new FLPan();
			for(var i:int =0;i<5;i++)
			{
				points[i] = [];
				for(var j:int =0;j<5;j++)
				{
					var p:FLPoint = flPan.getPoint(i,j);
					var gp:GamePoint = new GamePoint();
					gp.setPoint(p);
					this.addChild(gp);
					points[i][j] = gp;
					gp.x = 20+j*125;
					gp.y = 20+i*125;
				}
			}
		}
		
		public function onTouch(event:TouchEvent):void
		{
//			trace(event.localX,event.localY);
//			p.x = event.localX;
//			p.y = event.localY;
			var gp:GamePoint = event.target as GamePoint;
			if(gp!=null)
			{
				gp.onTouch();
			}
		}
	}
}